home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / SQL.H < prev    next >
C/C++ Source or Header  |  1993-10-19  |  7KB  |  271 lines

  1. /*****************************************************************
  2.  SQL.H - This is the the main include for ODBC Core functions.
  3.  
  4.  preconditions:
  5.   #include "windows.h"
  6.  
  7.  (C) Copyright 1990, 1991, 1992, 1993 By Microsoft Corp.
  8. *********************************************************************/
  9.  
  10. #ifndef __SQL
  11. #define __SQL
  12.  
  13. #ifdef __cplusplus
  14. extern "C" {                         /* Assume C declarations for C++ */
  15. #endif    /* __cplusplus */
  16.  
  17. /* generally useful constants */
  18. #define SQL_NTS                  -3  /* NTS = Null Terminated String  */
  19. #define SQL_SQLSTATE_SIZE         5  /* size of SQLSTATE              */
  20. #define SQL_MAX_MESSAGE_LENGTH  512  /* message buffer size           */
  21. #define SQL_MAX_DSN_LENGTH       32  /* maximum data source name size */
  22.  
  23. /* RETCODEs */
  24. #define SQL_ERROR             -1
  25. #define SQL_INVALID_HANDLE    -2
  26. #define SQL_NEED_DATA         99
  27. #define SQL_NO_DATA_FOUND    100
  28. #define SQL_SUCCESS            0
  29. #define SQL_SUCCESS_WITH_INFO  1
  30.  
  31. /* SQLFreeStmt defines */
  32. #define SQL_CLOSE              0
  33. #define SQL_DROP               1
  34. #define SQL_UNBIND             2
  35. #define SQL_RESET_PARAMS       3
  36.  
  37. /* SQLSetParam defines */
  38. #define SQL_C_DEFAULT  99
  39.  
  40. /* SQLTransact defines */
  41. #define SQL_COMMIT    0
  42. #define SQL_ROLLBACK  1
  43.  
  44. /* Standard SQL datatypes, using ANSI type numbering */
  45. #define SQL_CHAR      1
  46. #define SQL_NUMERIC   2
  47. #define SQL_DECIMAL   3
  48. #define SQL_INTEGER   4
  49. #define SQL_SMALLINT  5
  50. #define SQL_FLOAT     6
  51. #define SQL_REAL      7
  52. #define SQL_DOUBLE    8
  53. #define SQL_VARCHAR  12
  54.  
  55. #define SQL_TYPE_MIN   1
  56. #define SQL_TYPE_NULL  0
  57. #define SQL_TYPE_MAX  12
  58.  
  59. /* C datatype to SQL datatype mapping    SQL types 
  60.                                          ----------------------- */
  61. #define SQL_C_CHAR    SQL_CHAR       /* CHAR, VARCHAR, DECIMAL, NUMERIC */
  62. #define SQL_C_LONG    SQL_INTEGER    /* INTEGER          */
  63. #define SQL_C_SHORT   SQL_SMALLINT   /* SMALLINT         */
  64. #define SQL_C_FLOAT   SQL_REAL       /* REAL             */
  65. #define SQL_C_DOUBLE  SQL_DOUBLE     /* FLOAT, DOUBLE    */
  66.  
  67. /* NULL status constants.  These are used in SQLColumns, SQLColAttributes,
  68. SQLDescribeCol, and SQLSpecialColumns to describe the nullablity of a
  69. column in a table.  SQL_NULLABLE_UNKNOWN can be returned only by 
  70. SQLDescribeCol or SQLColAttributes.  It is used when the DBMS's meta-data
  71. does not contain this info.  */
  72. #define SQL_NO_NULLS         0
  73. #define SQL_NULLABLE         1
  74. #define SQL_NULLABLE_UNKNOWN 2
  75.  
  76. /* Special length values */
  77. #define SQL_NULL_DATA       -1
  78. #define SQL_DATA_AT_EXEC    -2
  79.  
  80. /* SQLColAttributes defines */
  81. #define SQL_COLUMN_COUNT            0
  82. #define SQL_COLUMN_NAME             1
  83. #define SQL_COLUMN_TYPE             2
  84. #define SQL_COLUMN_LENGTH           3
  85. #define SQL_COLUMN_PRECISION        4
  86. #define SQL_COLUMN_SCALE            5
  87. #define SQL_COLUMN_DISPLAY_SIZE     6
  88. #define SQL_COLUMN_NULLABLE         7
  89. #define SQL_COLUMN_UNSIGNED         8
  90. #define SQL_COLUMN_MONEY            9
  91. #define SQL_COLUMN_UPDATABLE       10
  92. #define SQL_COLUMN_AUTO_INCREMENT  11
  93. #define SQL_COLUMN_CASE_SENSITIVE  12
  94. #define SQL_COLUMN_SEARCHABLE      13
  95. #define SQL_COLUMN_TYPE_NAME       14
  96.  
  97. /* SQLColAttributes subdefines for SQL_COLUMN_UPDATABLE */
  98. #define SQL_ATTR_READONLY          0
  99. #define SQL_ATTR_WRITE             1
  100. #define SQL_ATTR_READWRITE_UNKNOWN 2
  101.  
  102. /* SQLColAttributes subdefines for SQL_COLUMN_SEARCHABLE */
  103. /* These are also used by SQLGetInfo                     */
  104. #define SQL_UNSEARCHABLE           0
  105. #define SQL_LIKE_ONLY              1
  106. #define SQL_ALL_EXCEPT_LIKE        2
  107. #define SQL_SEARCHABLE             3
  108.  
  109. /* SQLError defines */
  110. #define SQL_NULL_HENV    0
  111. #define SQL_NULL_HDBC    0
  112. #define SQL_NULL_HSTMT   0
  113.  
  114. /* environment specific definitions */
  115. #define SQL_API PASCAL FAR
  116.  
  117. #ifndef RC_INVOKED
  118. /* SQL portable types for C */
  119. typedef unsigned char       UCHAR;
  120. typedef signed char         SCHAR;
  121. typedef long int            SDWORD;
  122. typedef short int           SWORD;
  123. typedef unsigned long int   UDWORD;
  124. typedef unsigned short int  UWORD;
  125. typedef double              SDOUBLE;
  126. typedef long double         LDOUBLE;
  127. typedef float               SFLOAT;
  128.  
  129. typedef void FAR *          PTR;
  130.  
  131. typedef void FAR *          HENV;
  132. typedef void FAR *          HDBC;
  133. typedef void FAR *          HSTMT;
  134.  
  135. typedef int                 RETCODE;
  136.  
  137.  
  138. /* Core Function Prototypes */
  139.  
  140. RETCODE SQL_API SQLAllocConnect(
  141.     HENV        henv,
  142.     HDBC   FAR *phdbc);
  143.  
  144. RETCODE SQL_API SQLAllocEnv(
  145.     HENV   FAR *phenv);
  146.  
  147. RETCODE SQL_API SQLAllocStmt(
  148.     HDBC        hdbc,
  149.     HSTMT  FAR *phstmt);
  150.  
  151. RETCODE SQL_API SQLBindCol(
  152.     HSTMT       hstmt,
  153.     UWORD       icol,
  154.     SWORD       fCType,
  155.     PTR         rgbValue,
  156.     SDWORD      cbValueMax,
  157.     SDWORD FAR *pcbValue);
  158.  
  159. RETCODE SQL_API SQLCancel(
  160.     HSTMT       hstmt);
  161.  
  162. RETCODE SQL_API SQLColAttributes(
  163.     HSTMT        hstmt,
  164.     UWORD        icol,
  165.     UWORD        fDescType,
  166.     PTR          rgbDesc,
  167.     SWORD         cbDescMax,
  168.     SWORD   FAR *pcbDesc,
  169.     SDWORD  FAR *pfDesc);
  170.  
  171. RETCODE SQL_API SQLConnect(
  172.     HDBC        hdbc,
  173.     UCHAR  FAR *szDSN,
  174.     SWORD       cbDSN,
  175.     UCHAR  FAR *szUID,
  176.     SWORD       cbUID,
  177.     UCHAR  FAR *szAuthStr,
  178.     SWORD       cbAuthStr);
  179.  
  180. RETCODE SQL_API SQLDescribeCol(
  181.     HSTMT       hstmt,
  182.     UWORD       icol,
  183.     UCHAR  FAR *szColName,
  184.     SWORD       cbColNameMax,
  185.     SWORD  FAR *pcbColName,
  186.     SWORD  FAR *pfSqlType,
  187.     UDWORD FAR *pcbColDef,
  188.     SWORD  FAR *pibScale,
  189.     SWORD  FAR *pfNullable);
  190.  
  191. RETCODE SQL_API SQLDisconnect(
  192.     HDBC        hdbc);
  193.  
  194. RETCODE SQL_API SQLError(
  195.     HENV        henv,
  196.     HDBC        hdbc,
  197.     HSTMT       hstmt,
  198.     UCHAR  FAR *szSqlState,
  199.     SDWORD FAR *pfNativeError,
  200.     UCHAR  FAR *szErrorMsg,
  201.     SWORD       cbErrorMsgMax,
  202.     SWORD  FAR *pcbErrorMsg);
  203.  
  204. RETCODE SQL_API SQLExecDirect(
  205.     HSTMT       hstmt,
  206.     UCHAR  FAR *szSqlStr,
  207.     SDWORD      cbSqlStr);
  208.  
  209. RETCODE SQL_API SQLExecute(
  210.     HSTMT       hstmt);
  211.  
  212. RETCODE SQL_API SQLFetch(
  213.     HSTMT       hstmt);
  214.  
  215. RETCODE SQL_API SQLFreeConnect(
  216.     HDBC        hdbc);
  217.  
  218. RETCODE SQL_API SQLFreeEnv(
  219.     HENV        henv);
  220.  
  221. RETCODE SQL_API SQLFreeStmt(
  222.     HSTMT       hstmt,
  223.     UWORD       fOption);
  224.  
  225. RETCODE SQL_API SQLGetCursorName(
  226.     HSTMT       hstmt,
  227.     UCHAR  FAR *szCursor,
  228.     SWORD       cbCursorMax,
  229.     SWORD  FAR *pcbCursor);
  230.  
  231. RETCODE SQL_API SQLNumResultCols(
  232.     HSTMT       hstmt,
  233.     SWORD  FAR *pccol);
  234.  
  235. RETCODE SQL_API SQLPrepare(
  236.     HSTMT       hstmt,
  237.     UCHAR  FAR *szSqlStr,
  238.     SDWORD      cbSqlStr);
  239.  
  240. RETCODE SQL_API SQLRowCount(
  241.     HSTMT       hstmt,
  242.     SDWORD  FAR *pcrow);
  243.  
  244. RETCODE SQL_API SQLSetCursorName(
  245.     HSTMT       hstmt,
  246.     UCHAR  FAR *szCursor,
  247.     SWORD       cbCursor);
  248.  
  249. RETCODE SQL_API SQLSetParam(
  250.     HSTMT       hstmt,
  251.     UWORD       ipar,
  252.     SWORD       fCType,
  253.     SWORD       fSqlType,
  254.     UDWORD      cbColDef,
  255.     SWORD       ibScale,
  256.     PTR         rgbValue,
  257.     SDWORD  FAR *pcbValue);
  258.  
  259. RETCODE SQL_API SQLTransact(
  260.     HENV        henv,
  261.     HDBC        hdbc,
  262.     UWORD       fType);
  263.  
  264. #endif /* RC_INVOKED */
  265.  
  266. #ifdef __cplusplus
  267. }                                    /* End of extern "C" { */
  268. #endif    /* __cplusplus */
  269.  
  270. #endif  /* #ifndef __SQL */
  271.